-- @owner: @zou_jialiang050
-- @date: 2023/2/20
-- @testpoint: create function 使用原有语法创建函数指定opengauss侧函数选项，成功
-- @modified by @zou_jialiang050 2024/4/30:根据最新代码优化用例

--step1:建表;expect:成功
drop table if exists t_create_function_0027;
create table t_create_function_0027(cid int, account decimal(7,3), grade char(50));
insert into t_create_function_0027 values(001, 666.66);

--step2:create function 使用原有语法创建函数指定opengauss侧函数选项;expect:成功
drop function if exists f_create_function_0027;
create function f_create_function_0027(card_id int) returns char(50) leakproof as
$$
declare a char(50);
declare money decimal(7,3);
declare num int;
begin
select account into money from t_create_function_0027 where cid = card_id;
set num = truncate(money/100,0);
case num
when 0 then set a = '123';
when 1 then set a = '456';
else set a = '789';
end case;
return a;
end;
$$ language plpgsql;
/
select f_create_function_0027(1);
select pg_get_functiondef('f_create_function_0027'::regproc::oid);

--step3:清理环境;expect:成功
drop function if exists f_create_function_0027;
drop table if exists t_create_function_0027;